package com.quickask.entity;

import org.hibernate.annotations.*;

import javax.persistence.*;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;

/**
 * Created by NaSa on 2015/9/23.
 */
@Entity
@Table(name = "asknow_question_location_set", schema = "", catalog = "quickask")
@org.hibernate.annotations.Cache(usage= CacheConcurrencyStrategy.READ_WRITE, region = "com.quickask.entity.AsknowQuestionLocationSetEntity")
public class AsknowQuestionLocationSetEntity implements Serializable {
    private Integer questionId;  //问题的id
    private Byte type;  //定位类型
    private Double longitude; //经度
    private Double latitude;  //纬度
    private Double altitude;  //海拔高度
    private String locationDetail;  //详细地址
    private String geohash;  //geohash值
    private String provinceCode;  //省份编码
    private String cityCode;  //城市编码
    private String blockCode;  //区编码
    //private AsknowQuestionSetEntity asknowQuestionSetEntity;

    @Id
    @Column(name = "questionId", nullable = true, insertable = true, updatable = true)
    public Integer getQuestionId() {
        return questionId;
    }

    public void setQuestionId(Integer questionId) {
        this.questionId = questionId;
    }

    @Basic
    @Column(name = "type", nullable = true, insertable = true, updatable = true, scale = 1)
    public Byte getType() {
        return type;
    }

    public void setType(Byte type) {
        this.type = type;
    }

    @Basic
    @Column(name = "longitude", nullable = true, insertable = true, updatable = true, precision = 6)
    public Double getLongitude() {
        return longitude;
    }

    public void setLongitude(Double longitude) {
        this.longitude = longitude;
    }

    @Basic
    @Column(name = "latitude", nullable = true, insertable = true, updatable = true, precision = 6)
    public Double getLatitude() {
        return latitude;
    }

    public void setLatitude(Double latitude) {
        this.latitude = latitude;
    }

    @Basic
    @Column(name = "altitude", nullable = true, insertable = true, updatable = true, precision = 6)
    public Double getAltitude() {
        return altitude;
    }

    public void setAltitude(Double altitude) {
        this.altitude = altitude;
    }

    @Basic
    @Column(name = "locationDetail", nullable = true, insertable = true, updatable = true, length = 100)
    public String getLocationDetail() {
        return locationDetail;
    }

    public void setLocationDetail(String locationDetail) {
        this.locationDetail = locationDetail;
    }

    @Basic
    @Column(name = "geohash", nullable = true, insertable = true, updatable = true, length = 64)
    public String getGeohash() {
        return geohash;
    }

    public void setGeohash(String geohash) {
        this.geohash = geohash;
    }

    @Basic
    @Column(name = "provinceCode", nullable = true, insertable = true, updatable = true, length = 10)
    public String getProvinceCode() {
        return provinceCode;
    }

    public void setProvinceCode(String provinceCode) {
        this.provinceCode = provinceCode;
    }

    @Basic
    @Column(name = "cityCode", nullable = true, insertable = true, updatable = true, length = 10)
    public String getCityCode() {
        return cityCode;
    }

    public void setCityCode(String cityCode) {
        this.cityCode = cityCode;
    }

    @Basic
    @Column(name = "blockCode", nullable = true, insertable = true, updatable = true, length = 10)
    public String getBlockCode() {
        return blockCode;
    }

    public void setBlockCode(String blockCode) {
        this.blockCode = blockCode;
    }

//    @OneToOne(fetch = FetchType.LAZY,cascade = CascadeType.ALL, mappedBy = "asknowQuestionLocationSetEntity")
//    public AsknowQuestionSetEntity getAsknowQuestionSetEntity() {
//        return asknowQuestionSetEntity;
//    }
//
//    public void setAsknowQuestionSetEntity(AsknowQuestionSetEntity asknowQuestionSetEntity) {
//        this.asknowQuestionSetEntity = asknowQuestionSetEntity;
//    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof AsknowQuestionLocationSetEntity)) return false;

        AsknowQuestionLocationSetEntity that = (AsknowQuestionLocationSetEntity) o;

        if (questionId != null ? !questionId.equals(that.questionId) : that.questionId != null) return false;
        if (type != null ? !type.equals(that.type) : that.type != null) return false;
        if (longitude != null ? !longitude.equals(that.longitude) : that.longitude != null) return false;
        if (latitude != null ? !latitude.equals(that.latitude) : that.latitude != null) return false;
        if (altitude != null ? !altitude.equals(that.altitude) : that.altitude != null) return false;
        if (locationDetail != null ? !locationDetail.equals(that.locationDetail) : that.locationDetail != null)
            return false;
        if (geohash != null ? !geohash.equals(that.geohash) : that.geohash != null) return false;
        if (provinceCode != null ? !provinceCode.equals(that.provinceCode) : that.provinceCode != null) return false;
        if (cityCode != null ? !cityCode.equals(that.cityCode) : that.cityCode != null) return false;
        return !(blockCode != null ? !blockCode.equals(that.blockCode) : that.blockCode != null);

    }

    @Override
    public int hashCode() {
        int result = questionId != null ? questionId.hashCode() : 0;
        result = 31 * result + (type != null ? type.hashCode() : 0);
        result = 31 * result + (longitude != null ? longitude.hashCode() : 0);
        result = 31 * result + (latitude != null ? latitude.hashCode() : 0);
        result = 31 * result + (altitude != null ? altitude.hashCode() : 0);
        result = 31 * result + (locationDetail != null ? locationDetail.hashCode() : 0);
        result = 31 * result + (geohash != null ? geohash.hashCode() : 0);
        result = 31 * result + (provinceCode != null ? provinceCode.hashCode() : 0);
        result = 31 * result + (cityCode != null ? cityCode.hashCode() : 0);
        result = 31 * result + (blockCode != null ? blockCode.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "AsknowQuestionLocationSetEntity{" +
                "questionId=" + questionId +
                ", type=" + type +
                ", longitude=" + longitude +
                ", latitude=" + latitude +
                ", altitude=" + altitude +
                ", locationDetail='" + locationDetail + '\'' +
                ", geohash='" + geohash + '\'' +
                ", provinceCode='" + provinceCode + '\'' +
                ", cityCode='" + cityCode + '\'' +
                ", blockCode='" + blockCode + '\'' +
                '}';
    }
}
